package com.ruoyi.web.wapper;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.wapper.BaseControllerWrapper;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class SpeChannelUvCountWapper extends BaseControllerWrapper {

    public SpeChannelUvCountWapper(Map<String, Object> single) {
        super(single);
    }

    public SpeChannelUvCountWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Long uvNumber = (Long) map.get("uvNumber");
            Long regNumber = (Long) map.get("regNumber");
            if (ObjectUtil.isAllNotEmpty(uvNumber, regNumber)){
                map.put("regRate", NumberUtil.div(regNumber, uvNumber, 2));
            }

            Long proUvNumber = (Long) map.get("proUvNumber");
            if (ObjectUtil.isAllNotEmpty(proUvNumber, regNumber)){
                map.put("proRate", NumberUtil.div(proUvNumber, regNumber, 2));
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
